package com.haixiaoke.service.impl;

import java.util.List;

import cn.hutool.core.date.DateTime;
import com.haixiaoke.common.utils.DateUtils;
import com.haixiaoke.domain.SmartLockFace;
import com.haixiaoke.mapper.SmartLockFaceMapper;
import com.haixiaoke.service.ISmartLockFaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 智能锁授权人脸信息Service业务层处理
 *
 * @author xiaolong
 * @date 2023-06-10
 */
@Service
public class SmartLockFaceServiceImpl implements ISmartLockFaceService {
    @Autowired
    private SmartLockFaceMapper smartLockFaceMapper;

    /**
     * 查询智能锁授权人脸信息
     *
     * @param faceId 智能锁授权人脸信息主键
     * @return 智能锁授权人脸信息
     */
    @Override
    public SmartLockFace selectSmartLockFaceByFaceId(Long faceId) {
        return smartLockFaceMapper.selectSmartLockFaceByFaceId(faceId);
    }

    /**
     * 查询智能锁授权人脸信息列表
     *
     * @param smartLockFace 智能锁授权人脸信息
     * @return 智能锁授权人脸信息
     */
    @Override
    public List<SmartLockFace> selectSmartLockFaceList(SmartLockFace smartLockFace) {
        return smartLockFaceMapper.selectSmartLockFaceList(smartLockFace);
    }

    /**
     * 新增智能锁授权人脸信息
     *
     * @param smartLockFace 智能锁授权人脸信息
     * @return 结果
     */
    @Override
    public int insertSmartLockFace(SmartLockFace smartLockFace) {
        smartLockFace.setCreateTime(DateUtils.getNowDate());
        return smartLockFaceMapper.insertSmartLockFace(smartLockFace);
    }

    /**
     * 修改智能锁授权人脸信息
     *
     * @param smartLockFace 智能锁授权人脸信息
     * @return 结果
     */
    @Override
    public int updateSmartLockFace(SmartLockFace smartLockFace) {
        smartLockFace.setUpdateTime(DateUtils.getNowDate());
        return smartLockFaceMapper.updateSmartLockFace(smartLockFace);
    }

    /**
     * 批量删除智能锁授权人脸信息
     *
     * @param faceIds 需要删除的智能锁授权人脸信息主键
     * @return 结果
     */
    @Override
    public int deleteSmartLockFaceByFaceIds(Long[] faceIds) {
        return smartLockFaceMapper.deleteSmartLockFaceByFaceIds(faceIds);
    }

    /**
     * 删除智能锁授权人脸信息信息
     *
     * @param faceId 智能锁授权人脸信息主键
     * @return 结果
     */
    @Override
    public int deleteSmartLockFaceByFaceId(Long faceId) {
        return smartLockFaceMapper.deleteSmartLockFaceByFaceId(faceId);
    }

    /**
     * 删除智能锁授权人脸信息信息
     *
     * @param returnFaceId 厂商授权id
     * @return 结果
     */
    @Override
    public int deleteSmartLockFaceByReturnFaceId(Long returnFaceId) {
        return smartLockFaceMapper.deleteSmartLockFaceByReturnFaceId(returnFaceId);
    }

    @Override
    public int deleteSmartLockFaceBySnAndIdentification(String sn, String identification) {
        return smartLockFaceMapper.deleteSmartLockFaceBySnAndIdentification(sn,identification);
    }

    @Override
    public SmartLockFace selectSmartLockPwdBySNAndIdentification(String sn, String identification) {
        return smartLockFaceMapper.selectSmartLockPwdBySNAndIdentification(sn,identification);
    }

    public int deleteSmartLockFaceBySn(String sn) {
        return smartLockFaceMapper.deleteSmartLockFaceBySn(sn);
    }

    public int deleteSmartLockFaceByEndTime(DateTime date) {
        return smartLockFaceMapper.deleteSmartLockFaceByEndTime(date);
    }
}
